import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import Components from 'unplugin-vue-components/vite'
import { VueUseComponentsResolver } from 'unplugin-vue-components/resolvers'
import AutoImport from 'unplugin-auto-import/vite'
import uniLayouts from '@uni-helper/vite-plugin-uni-layouts'
export default defineConfig(async () => {
  const UnoCSS = (await import('unocss/vite')).default
  return {
    plugins: [
      uniLayouts(),
      uni(),
      UnoCSS(),
      Components({
        resolvers: [VueUseComponentsResolver()],
      }),
      AutoImport({
        imports: ['vue'],
      }),
    ],
    optimizeDeps: {
      exclude:
        process.env.UNI_PLATFORM === 'h5' && process.env.NODE_ENV === 'development'
          ? ['wot-design-uni']
          : [],
    },
  }
})
